<%@page import="java.io.*"%>
<%@page import="com.google.gson.Gson"%>
<%@page import="com.hutao.medical.common.util.DocPather"%>
<%@page language="java" import="java.util.*"%>
<%@page language="java" contentType="text/html;charset=utf-8"%>
<%
Map<String,String> map = new HashMap<String,String>();
Gson gson = new Gson();
try{
	//String $e6s5f9p8e8q6p1x1t2 = request.getContentType();//上传表单内容类型
	int $e6s5f9p8e8z3t2n4 = request.getContentLength();//上传表单内容总长（字节）
	int $o8k3q4e8z3t2n4 = 1024*1024*2;
	if ($e6s5f9p8e8z3t2n4 > $o8k3q4e8z3t2n4){//如果大于2M,退回
		map.put("error","file's size > "+$o8k3q4e8z3t2n4);
		System.out.println("upOne error:"+"file's size > "+$o8k3q4e8z3t2n4);
		out.print(gson.toJson(map));
		return;
	}
 	String fileName = request.getHeader("-fileName");

 	System.out.println("fileName:"+fileName);
	
/*String mrId = request.getHeader("-mrId");
	String filename = new java.util.Date().getTime()+"."+filetype;
	DocPather docPather = ApplicationConstants.docPather;
	String imagePath = docPather.getUploadImagePath(mrId,filename,orgCode);//// */

	String imagePath = "D://publics/upload/tempImgPath"+fileName;
	System.out.println("- 上传路径=>"+imagePath);
	int RLen = 1024*4;
	byte[] ReadByte = new byte[RLen];//输入流缓冲区		
	int ReadCount = 0;//记录从输入流中每次实际读取的字节数
	int $e6h3t7t2j1h3w0t2 = 0;
	ServletInputStream input = request.getInputStream();//取得输入流
	
	File $I1v2u5g0p1d6 = new File(new File(imagePath).getParent());
	if (!$I1v2u5g0p1d6.exists()){
		$I1v2u5g0p1d6.mkdirs();
	}
	BufferedOutputStream outStream = new BufferedOutputStream(new FileOutputStream(imagePath));

	while ((ReadCount=input.readLine(ReadByte,0,RLen)) > -1){
		$e6h3t7t2j1h3w0t2 += ReadCount;
		outStream.write(ReadByte,0,ReadCount);
	}
	outStream.flush();
	
	input.close();
	outStream.close();
	ReadByte = null;
	
	if ($e6h3t7t2j1h3w0t2 < 3584){
		map.put("SUCCESS","noUp");
		System.out.println("- upOne=>noUp");
	}else{
		map.put("filename",imagePath);
		map.put("randomNum",randomNum);
		map.put("SUCCESS","1");
		System.out.println("filename");
	}
}catch(Exception ex){
	System.out.println("upOne ex:"+ex);
	map.put("SUCCESS","0");
}

out.print(gson.toJson(map));
%>